package com.spring.sd;

import com.spring.sd.aware.MyBean;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

/**
 * Aware 接口用于注入一些与容器相关的信息，比如：
 *
 * BeanNameAware 注入 Bean 的名字
 * BeanFactoryAware 注入 BeanFactory 容器
 * ApplicationContextAware 注入 ApplicationContext 容器
 * EmbeddedValueResolverAware 解析 ${}
 *
 */
public class AwareApplication {

    public static void main(String[] args) {
        step1();

    }

    public static void step1() {
        GenericApplicationContext context = new GenericApplicationContext();
        context.registerBean("myBean", MyBean.class);

        context.registerBean(AutowiredAnnotationBeanPostProcessor.class);
        context.registerBean(CommonAnnotationBeanPostProcessor.class);

        context.refresh();
        context.close();
    }
}
